<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <meta name="viewport"
        content="maximum-scale=1.0,minimum-scale=1.0,user-scalable=0,width=device-width,initial-scale=1.0" />
    <meta name="format-detection" content="telephone=no,email=no,date=no,address=no">
    <link rel="stylesheet" type="text/css" href="../css/aui.2.0.css" />
    <link rel="stylesheet" type="text/css" href="../css/aui-flex.css" />
    <style>
    </style>
</head>
<style>
    .home:before {
        content: url(../image/home.png);
    }

    .refresh:before {
        content: url(../image/refresh.png);
    }

    .company:before {
        content: url(../image/company.png);
    }

    .pa-title {
        font-size: 17px;
        color: black;
        font-weight: bold;
    }

    .pa-title-content {
        font-size: 17px;
        color: black;
    }

    body {
        background-color: #D9D8DB;
    }

    .pa_kbdd_t {
        background-color: #254060;
        height: 210px;
        color: white;
        overflow: auto;
        border-bottom: 2px solid gray;
    }

    .pa_kbdd__bottom_t {
        background-color: #254060;
        height: 40px;
        color: white;
    }

    .pa_kbdd_but {
        height: 56px;
        line-height: 56px;
        float: left;
        width: 60px;
        font-size: 18px;
        color: white;
        text-align: center;
        background-color: #528302;
        margin-left: 8px;
    }

    .pa_kbddProd {
        font-size: 15px;
        float: left;
        height: 56px;
        line-height: 56px;
        text-align: center;
        margin-left: 5px;
    }

    .pa_kbddProd_con {
        background-color: white;
        float: left;
        width: 100px;
        margin-top: 13px;
    }

    .pa_kbddProd_inner {
        background-color: #D9D8DB;
        border: 0;
        float: left;
        margin-left: 10px;
    }

    .radioClass {
        margin-top: 7px;
        float: left;
        margin-left: 20px;
    }

    .radioClassName {
        float: left;
        margin-left: 5px;
        margin-top: 6px;
    }

    .bottom_content {
        height: 100%;
        width: 20%;
        float: left;
        border: 1px solid gray;
        font-size: 16px;
        line-height: 35px;
        text-align: center;
    }

    .confirm_but {
        background-color: #528302;
        width: 80%;
        margin-left: 10%;
        margin-top: 1.5%;
        /* display: none; */
    }

    p {
        font-size: 17px;
        color: black;
        font-weight: bold;
        text-align: center;
    }

    table {
        width: 100%;
        table-layout: fixed;
        word-wrap: break-word;
    }

    td {
        white-space: nowrap;
        text-overflow: ellipsis;
        overflow: hidden;
    }
</style>

<body>
    <header class="aui-bar aui-bar-nav" style="background-color: #D9D8DB">
        <div style="width: 10%;height: 60px;float: left;padding-top: 6px;">
            <a class="aui-pull-left aui-btn ">
                <span class="aui-iconfont company"></span>
            </a>
        </div>
        <div style="width: 10%;height: 60px;float: left;">
            <div style="text-align: left;">
                <span class="pa-title">富晟久泰</span>
            </div>
        </div>
        <div style="width: 70%;height: 60px;float: left;">
            <div style="width:20%; float: left; text-align: left;">
                <span class="pa-title-content" id="locationName"></span>
            </div>
            <div style="width:25%; float: left; text-align: left;">
                <span class="pa-title-content" id="workCenterName"></span>
            </div>
            <div style="width:15%; float: left; text-align: left;">
                <span class="pa-title-content" id="workCellName"></span>
            </div>
            <div style="width:40%; float: left; text-align: left;">
                <span class="pa-title-content" id="nowDate"></span>
            </div>
        </div>
        <div style="width: 5%;height: 50px;float: left;">
            <a class="aui-pull-right aui-btn " onclick="refresh()">
                <span class="aui-iconfont refresh"></span>
            </a>
        </div>
        <div style="width: 5%;height: 50px;float: left;">
            <a class="aui-pull-right aui-btn" onclick="closeWin()">
                <span class="aui-iconfont home"></span>
            </a>
        </div>
    </header>
    <div class="aui-content">
        <div class="aui-flex-col aui-flex-center" style="height: 30px;">
            <div class="aui-flex-item-12">
                <p>开班点检</p>
            </div>
        </div>
        <div class="aui-flex-col aui-flex-center">
            <div class="aui-flex-item-12">
                <div class="aui-flex-item-10">
                    <div class="aui-flex-col">
                        <div class="aui-flex-item-12">
                            <div class="aui-list-item-inner" style="background-color: #D9D8DB; border: 0;float: left;">
                                <div class="aui-list-item-label pa_kbddProd"> 生产日期:</div>
                                <div class="aui-list-item-input pa_kbddProd_con" onclick="timePicker('prodDate');">
                                    <input type="text" placeholder="选择日期" class="aui-input" id="prodDate"
                                        style="font-size:15px;height: 30px;min-height: 30px;">
                                </div>
                            </div>

                            <div class="aui-list-item-inner pa_kbddProd_inner">
                                <div class="aui-list-item-label pa_kbddProd">班次:</div>
                                <div class="aui-list-item-input pa_kbddProd_con" style="width: 70px;">
                                    <select id="shiftCode" style="font-size:15px;height: 30px;min-height: 30px;">
                                    </select>
                                </div>
                            </div>

                            <div class="aui-list-item-inner pa_kbddProd_inner pa_kbddProd_inner">
                                <div class="aui-list-item-label pa_kbddProd">班组:</div>
                                <div class="aui-list-item-input pa_kbddProd_con" style="width: 100px;">
                                    <select id="teamCode" style="font-size:15px;height: 30px;min-height: 30px;">
                                    </select>
                                </div>
                            </div>

                            <div class="aui-list-item-inner pa_kbddProd_inner" style="display: none;">
                                <div class="aui-list-item-label pa_kbddProd">机台:</div>
                                <div class="aui-list-item-input pa_kbddProd_con">
                                    <input type="text" class="aui-input" id="lineCode" disabled="true"
                                        style="font-size:15px;height: 30px;min-height: 30px;">
                                </div>
                            </div>

                            <div class="aui-list-item-inner pa_kbddProd_inner" style="display: none;">
                                <div class="aui-list-item-label pa_kbddProd">类别:</div>
                                <div class="aui-list-item-input pa_kbddProd_con" style="width: 70px;">
                                    <select id="type" style="font-size:15px;height: 30px;min-height: 30px;">
                                        <option value="开机">开机</option>
                                        <option value="换模">换模</option>
                                        <option value="换模">停机</option>
                                    </select>
                                </div>
                            </div>
                        </div>
                    </div>
                </div>

                <div class="aui-flex-item-2">
                    <div class="aui-flex-col ">
                        <div class="aui-flex-item-12">

                            <div class="pa_kbdd_but" onclick="doSearch()">查询
                            </div>
                            <div class="pa_kbdd_but" onclick="save()">
                                提交
                            </div>
                        </div>
                    </div>
                </div>
            </div>
        </div>

        <div class="aui-flex-col aui-flex-center" style="margin-top: 5px;">
            <div class="aui-flex-item-12">
                <div class="aui-flex-col pa_kbdd_t">
                    <div class="aui-flex-item-12">
                        <div style="height: 100%;width: 100%;">
                            <table class="table" border="1px solid gray" cellspacing="0" cellpadding="0">
                                <thead>
                                    <tr style="text-align: center;color: white;font-size: 16px;height: 30px;">
                                        <td algin='center' style="width:4%">分类</td>
                                        <td algin='center' style="width:4%">序号</td>
                                        <td algin='center' style="width:14%">点检项目</td>
                                        <td algin='center' style="width:6%">点检方法</td>
                                        <td algin='center' style="width:20%">接受标准</td>
                                        <td algin='center' style="width:10%">点检结果</td>
                                    </tr>
                                </thead>
                                <tbody id="chkTemplateDataHtml">
                                </tbody>
                            </table>
                        </div>
                    </div>
                </div>
            </div>
        </div>
        <div style="height: 10px;background-color: #254060;"></div>
        <div class="aui-flex-col aui-flex-center">
            <div class="aui-flex-item-12 pa_kbdd__bottom_t">
                <div class="bottom_content" style="border-top: 2px solid gray;">
                    作业员签字
                </div>
                <div class="bottom_content" style="border-top: 2px solid gray;">
                    <span id="empCode_1"></span>
                </div>
                <div class="bottom_content" style="width: 15%;border-top: 2px solid gray;">
                    <span id="empName_1"></span>
                </div>
                <div class="bottom_content" style="width: 30%;border-top: 2px solid gray;">
                    <span id="date_1"></span>
                </div>
                <div class="bottom_content" style="width: 15%;border-top: 2px solid gray;">
                    <span id="but_1_1" style="display: none;">已确认</span>
                    <div id="but_1_2" class="confirm_but" style="margin-top: 1%;" onclick="confirm(1)">确认
                    </div>
                </div>
            </div>

            <div class="aui-flex-item-12 pa_kbdd__bottom_t" style="display: none;">
                <div class="bottom_content">
                    工艺员签字
                </div>
                <div class="bottom_content">
                    <span id="empCode_2"></span>
                </div>
                <div class="bottom_content" style="width: 15%;">
                    <span id="empName_2"></span>
                </div>
                <div class="bottom_content" style="width: 30%;">
                    <span id="date_2"></span>
                </div>
                <div class="bottom_content" style="width: 15%;">
                    <span id="but_2_1" style="display: none;">已确认</span>
                    <div id="but_2_2" class="confirm_but" onclick="confirm(2)">确认
                    </div>
                </div>
            </div>
            <div class="aui-flex-item-12 pa_kbdd__bottom_t" style="display: none;">
                <div class="bottom_content">
                    设备签字
                </div>
                <div class="bottom_content">
                    <span id="empCode_3"></span>
                </div>
                <div class="bottom_content" style="width: 15%;">
                    <span id="empName_3"></span>
                </div>
                <div class="bottom_content" style="width: 30%;">
                    <span id="date_3"></span>
                </div>
                <div class="bottom_content" style="width: 15%;">
                    <span id="but_3_1" style="display: none;">已确认</span>
                    <div id="but_3_2" class="confirm_but" onclick="confirm(3)">确认
                    </div>
                </div>
            </div>
            <div class="aui-flex-item-12 pa_kbdd__bottom_t" style="display: none;">
                <div class="bottom_content">
                    班长签字
                </div>
                <div class="bottom_content">
                    <span id="empCode_4"></span>
                </div>
                <div class="bottom_content" style="width: 15%;">
                    <span id="empName_4"></span>
                </div>
                <div class="bottom_content" style="width: 30%;">
                    <span id="date_4"></span>
                </div>
                <div class="bottom_content" style="width: 15%;">
                    <span id="but_4_1" style="display: none;">已确认</span>
                    <div id="but_4_2" class="confirm_but" onclick="confirm(4)">确认
                    </div>
                </div>
            </div>
        </div>
    </div>
</body>
<script type="text/javascript" src="../script/api.js"></script>
<script type="text/javascript" src="../script/jquery-1.8.2.min.js"></script>
<script type="text/javascript" src="../script/public.js"></script>
<script type="text/javascript">

    var equipUniqueId = "";
    var tableList = [];
    var chkBillId = "";

    //初始化
    apiready = function () {
        //获取设备唯一号
        equipUniqueId = localStorage.getItem('equipUniqueId');
        //产线工位信息
        $("#locationName").html(api.pageParam.locationName);
        $("#workCenterName").html(api.pageParam.workCenterName);
        $("#workCellName").html(api.pageParam.workCellName);
        $("#nowDate").html(getTimeCommon());
        //机台
        $("#lineCode").val(api.pageParam.workCenterName);

        //当前时间刷新
        window.setInterval("getTime()", 1000);

        //1:初始化当前日期
        crateDate();

        //2:查询班组班次下拉框
        doSearchTeamShift();
    }

    //时间刷新
    function getTime() {
        $("#nowDate").html(getTimeCommon());
    }

    //获取当前日期
    function crateDate() {
        if (api.pageParam.proddate == null || api.pageParam.proddate == "" || api.pageParam.proddate == undefined) {
            var date = new Date();
            var year = date.getFullYear();
            var month = date.getMonth() + 1 < 10 ? "0" + (date.getMonth() + 1) : date.getMonth() + 1;
            var day = date.getDate() < 10 ? "0" + date.getDate() : date.getDate();
            $("#prodDate").val(year + "-" + month + "-" + day);
        } else {
            $("#prodDate").val(api.pageParam.proddate);
        }
    }

    //时间选择器
    function timePicker(id) {
        api.openPicker({
            type: 'date',
            date: new Date(),
            title: '选择日期'
        }, function (ret, err) {
            if (ret) {
                var monthTemp = (ret.month < 10 ? '0' + ret.month : ret.month);
                var dayTemp = (ret.day < 10 ? '0' + ret.day : ret.day);
                var date = ret.year + "-" + monthTemp + "-" + dayTemp;
                $("#" + id).val(date);

                doSearch();
            }
        });
    }

    //班组下拉框
    function doSearchTeamShift() {
        var un = localStorage.getItem('un');
        var serverUrl = localStorage.getItem('serverUrl');
        var url = serverUrl + "/app/getAssemblyTeam";
        var data = {
            values: {
                workCenterCode: api.pageParam.workCenterCode,
                clientCode: equipUniqueId,
                un: un,
            }
        };
        var params = new Object();
        params.url = url;
        params.dataType = 'json';
        params.method = 'post';

        ajaxForData(params, data, false, function (ret, err) {
            if (ret) {
                var data = JSON.stringify(ret);
                var myobj = eval("(" + data + ")");

                //成功
                if (myobj.code == 0) {

                    //班組賦值
                    var list = eval(myobj.list);
                    var html = "<option value=''>--请选择--</option>";
                    for (var i = 0; i < list.length; i++) {
                        html += "<option value='" + list[i].code + "'>" + list[i].name + "</option>";
                    }
                    $api.html($api.byId("teamCode"), html);
                    $("#teamCode").val(api.pageParam.teamCode);

                    //班次赋值
                    var listShift = eval(myobj.listShift);
                    var htmlShift = "<option value=''>--请选择--</option>";
                    for (var i = 0; i < listShift.length; i++) {
                        htmlShift += "<option value='" + listShift[i].code + "'>" + listShift[i].name + "</option>";
                    }
                    $api.html($api.byId("shiftCode"), htmlShift);
                    $("#shiftCode").val(api.pageParam.shiftCode);

                    //传输参数日期班组班次不为空，查询数据
                    if (api.pageParam.teamCode != null && api.pageParam.teamCode != "" && api.pageParam.teamCode != undefined) {
                        doSearch();
                    }
                } else {
                    api.toast({
                        msg: myobj.message,
                        duration: 3000
                    });
                }
            } else {
                alert("网络连接超时!")
            }
        });
    }

    //查询检测信息
    function doSearch() {
        var workCellCode = "";
        //是否按工位查询：0否，1是
        var cjFlag = api.pageParam.cjFlag;
        if ("1" == cjFlag) {
            workCellCode = api.pageParam.workCellCode;
        }

        var proddate = $("#prodDate").val();    //计划日期
        var shiftCode = $("#shiftCode").val();  //班次
        var teamCode = $("#teamCode").val();    //班组
        var type = $("#type").val();            //类别

        //form表单非空校验
        var flag = formChk(proddate, shiftCode, teamCode, type);
        if (!flag) {
            return;
        }

        var un = localStorage.getItem('un');
        var serverUrl = localStorage.getItem('serverUrl');
        var url = serverUrl + "/app/getAssemblyChkTemplateData";
        var data = {
            values: {
                workCenterCode: api.pageParam.workCenterCode,
                workCenterName: api.pageParam.workCenterName,
                workCellCode: workCellCode,
                proddate: proddate,
                shiftCode: shiftCode,
                teamCode: teamCode,
                type: type,
                un: un,
            }
        };
        var params = new Object();
        params.url = url;
        params.dataType = 'json';
        params.method = 'post';

        ajaxForData(params, data, false, function (ret, err) {
            if (ret) {
                var data = JSON.stringify(ret);
                var myobj = eval("(" + data + ")");

                //成功
                if (myobj.code == 0) {

                    //班組賦值
                    var list = eval(myobj.list);
                    tableList = list;
                    chkBillId = myobj.chkBillId;
                    var html = "";
                    //遍历
                    for (var i = 0; i < list.length; i++) {
                        var itemId = "citem" + i;
                        var chkBz_new = '';
                        console.log(list[i].chkBz)
                        for (let j = 0; j < list[i].chkBz.length; j += 28) {
                            chkBz_new += list[i].chkBz.substring(j, j + 28) + '<br>';
                        }
                        html += "<tr style='text-align: center;color: white;font-size: 14px;height:30px;'>";
                        html += "<td name='checkCataName'>" + list[i].checkCataName + "</td>";
                        html += "<td name='index'>" + (i + 1) + "</td>";
                        html += "<td name='citemName'>" + list[i].citemName + "</td>";
                        html += "<td name='chkTypeFunc'>" + list[i].chkTypeFunc + "</td>";
                        html += "<td name='chkBz'>" + chkBz_new + "</td>";
                        html += "<td name='chkResult'>";

                        //定量-手动输入
                        if ("0" == list[i].controlType) {

                            var minValue = list[i].minValue;
                            var maxValue = list[i].maxValue;
                            var standardValue = list[i].standardValue;
                            var chkValue = list[i].chkValue;
                            var valContent = "上限值：" + maxValue + " 下限值：" + minValue + " 标准值：" + standardValue;

                            html += "<input type='number' style='height:30px;min-height:30px;font-size:14px;color:white;text-align:center;' placeholder='" + valContent + "' />";

                            //定性-多选
                        } else if ("1" == list[i].controlType) {
                            var citemDs = eval(list[i].citemDs);
                            for (var j = 0; j < citemDs.length; j++) {
                                var citemDId = citemDs[j].id;
                                var citemDCode = citemDs[j].citemDCode;
                                var citemDName = citemDs[j].citemDName;
                                //0待选，1未选，2已选
                                var selectFlag = citemDs[j].selectFlag;
                                //默认选项：1是，2否
                                var isDefault = citemDs[j].isDefault;

                                if (selectFlag == "2") {
                                    html += "<input class='radioClass' type='checkbox' name=\"" + itemId + "\" value=\"" + citemDId + "\" checked><div class='radioClassName'>" + citemDName + "</div>";
                                } else {
                                    if (isDefault == "1") {
                                        html += "<input class='radioClass' type='checkbox' name=\"" + itemId + "\" value=\"" + citemDId + "\" checked><div class='radioClassName'>" + citemDName + "</div>";
                                    } else {
                                        html += "<input class='radioClass' type='checkbox' name=\"" + itemId + "\" value=\"" + citemDId + "\" ><div class='radioClassName'>" + citemDName + "</div>";
                                    }
                                }
                            }

                            //定性-单选
                        } else {
                            var citemDs = eval(list[i].citemDs);
                            for (var j = 0; j < citemDs.length; j++) {
                                var citemDId = citemDs[j].id;
                                var citemDName = citemDs[j].citemDName;
                                //0待选，1未选，2已选
                                var selectFlag = citemDs[j].selectFlag;
                                //默认选项：1是，2否
                                var isDefault = citemDs[j].isDefault;
                                if (selectFlag == "2") {
                                    html += "<input type='radio' class='radioClass'  name=\"" + itemId + "\" value=\"" + citemDId + "\" checked><div class='radioClassName'>" + citemDName + "</div>";
                                } else {
                                    // if (isDefault == "1") {
                                    //     html += "<input type='radio' class='radioClass'  name=\"" + itemId + "\" value=\"" + citemDId + "\" checked><div class='radioClassName'>" + citemDName + "</div>";
                                    // } else {
                                    html += "<input type='radio' class='radioClass'  name=\"" + itemId + "\" value=\"" + citemDId + "\"><div class='radioClassName'>" + citemDName + "</div>";
                                    // }
                                }
                            }
                        }

                        html += "</td>";
                        html += "</tr>";
                    }
                    $api.html($api.byId("chkTemplateDataHtml"), html);

                    if (list != null && tableList.length > 0) {
                        //作业员
                        if (myobj.empCode_1 != null && myobj.empCode_1 != "" && myobj.empCode_1 != undefined) {
                            document.getElementById("but_1_1").style.display = "block";
                            document.getElementById("but_1_2").style.display = "none";
                            $("#empCode_1").html(myobj.empCode_1);
                            $("#empName_1").html(myobj.empCode_1);
                            $("#date_1").html(myobj.date_1);
                        } else {
                            document.getElementById("but_1_1").style.display = "none";
                            document.getElementById("but_1_2").style.display = "block";
                            $("#empCode_1").html("");
                            $("#empName_1").html("");
                            $("#date_1").html("");
                        }

                        //工艺员
                        if (myobj.empCode_2 != null && myobj.empCode_2 != "" && myobj.empCode_2 != undefined) {
                            document.getElementById("but_2_1").style.display = "block";
                            document.getElementById("but_2_2").style.display = "none";
                            $("#empCode_2").html(myobj.empCode_2);
                            $("#empName_2").html(myobj.empCode_2);
                            $("#date_2").html(myobj.date_2);
                        } else {
                            document.getElementById("but_2_1").style.display = "none";
                            document.getElementById("but_2_2").style.display = "block";
                            $("#empCode_2").html("");
                            $("#empName_2").html("");
                            $("#date_2").html("");
                        }

                        //设备
                        if (myobj.empCode_3 != null && myobj.empCode_3 != "" && myobj.empCode_3 != undefined) {
                            document.getElementById("but_3_1").style.display = "block";
                            document.getElementById("but_3_2").style.display = "none";
                            $("#empCode_3").html(myobj.empCode_3);
                            $("#empName_3").html(myobj.empCode_3);
                            $("#date_3").html(myobj.date_3);
                        } else {
                            document.getElementById("but_3_1").style.display = "none";
                            document.getElementById("but_3_2").style.display = "block";
                            $("#empCode_3").html("");
                            $("#empName_3").html("");
                            $("#date_3").html("");
                        }
                        if (myobj.empCode_4 != null && myobj.empCode_4 != "" && myobj.empCode_4 != undefined) {
                            document.getElementById("but_4_1").style.display = "block";
                            document.getElementById("but_4_2").style.display = "none";
                            $("#empCode_4").html(myobj.empCode_4);
                            $("#empName_4").html(myobj.empCode_4);
                            $("#date_4").html(myobj.date_4);
                        } else {
                            document.getElementById("but_4_1").style.display = "none";
                            document.getElementById("but_4_2").style.display = "block";
                            $("#empCode_4").html("");
                            $("#empName_4").html("");
                            $("#date_4").html("");
                        }
                    }
                } else {
                    josnList = [];
                    chkBillId = "";
                    $api.html($api.byId("chkTemplateDataHtml"), "");
                    api.toast({
                        msg: myobj.message,
                        duration: 3000
                    });
                }
            } else {
                josnList = [];
                chkBillId = "";
                alert("网络连接超时!")
            }
        });
    }

    //确认,刷卡
    function confirm(index) {
        var dialogBox = api.require('dialogBox');
        dialogBox.input({
            keyboardType: 'default',
            texts: {
                title: '',
                placeholder: '扫描/录入卡号',
                leftBtnTitle: '取消',
                rightBtnTitle: '确定'
            },
            styles: {
                bg: '#fff',
                corner: 2,
                w: 300,
                h: 240,
                title: {
                    h: 60,
                    alignment: 'center',
                    size: 14,
                    color: '#000',
                    marginT: 30,
                },
                input: {
                    h: 60,
                    y: 30,
                    marginT: 15,
                    marginLeft: 10,
                    marginRight: 10,
                    textSize: 20,
                    textColor: '#000',
                    corner: 5,                  //（可选项）数字类型；对输入框圆角大小；默认：0

                },
                dividingLine: {
                    width: 0.5,
                    color: '#696969'
                },
                left: {
                    bg: 'rgba(0,0,0,0)',
                    color: '#007FFF',
                    size: 12,
                    h: 40,                //(可选项) 数字类型；右边按钮的高度；默认：40
                    w: 60,                   //(可选项) 数字类型；左边按钮的宽度；默认：提示框的宽度的一半
                    marginB: 10,            //(可选项) 数字类型；左边按离底部的边距；默认：0
                    corner: 5,              //(可选项) 数字类型；左边按钮的圆角；默认：0
                    widhtBorder: 1,         //(可选项) 数字类型；左边按钮的边宽；默认：0
                    normalBorderColor: '#778899', //(可选项) 数字类型；左边按钮的边宽颜色；默认：'rgba(0,0,0,0)'
                    activeBorderColor: '#0000CD', //(可选项) 数字类型；左边按钮的高亮状态下边宽颜色；默认：'rgba(0,0,0,0)'
                    activeColor: '#006400', //(可选项) 数字类型；左边按钮的高亮状态下标题颜色；默认：'rgba(0,0,0,0)'
                    activeBg: '#6B8E23'   //(可选项) 数字类型；左边按钮的高亮状态下背景颜色；默认：'rgba(0,0,0,0)'
                },
                right: {
                    bg: 'rgba(0,0,0,0)',
                    color: '#007FFF',
                    size: 12,
                    h: 40,                //(可选项) 数字类型；右边按钮的高度；默认：40
                    w: 60,                   //(可选项) 数字类型；右边按钮的宽度；默认：提示框的宽度的一半
                    marginB: 10,            //(可选项) 数字类型；右边按离底部的边距；默认：0
                    corner: 5,              //(可选项) 数字类型；右边按钮的圆角；默认：0
                    widhtBorder: 1,         //(可选项) 数字类型；右边按钮的边宽；默认：0
                    normalBorderColor: '#778899', //(可选项) 数字类型；右边按钮的边宽颜色；默认：'rgba(0,0,0,0)'
                    activeBorderColor: '#0000CD', //(可选项) 数字类型；右边按钮的高亮状态下边宽颜色；默认：'rgba(0,0,0,0)'
                    activeColor: '#006400', //(可选项) 数字类型；右边按钮的高亮状态下标题颜色；默认：'rgba(0,0,0,0)'
                    activeBg: '#6B8E23'   //(可选项) 数字类型；右边按钮的高亮状态下背景颜色；默认：'rgba(0,0,0,0)'
                }
            }
        }, function (ret) {
            //去掉回车
            ret.text = ret.text.replace(/[\r\n]/g, "");
            //工号
            var empNo = ret.text;
            //取消
            if (ret.eventType == 'left') {
                dialogBox.close({
                    dialogName: 'input'
                });

                //确定
            } else {

                //卡号必输校验
                if (empNo == null || empNo == "" || empNo == undefined) {
                    api.toast({
                        msg: "请扫描/录入卡号!",
                        duration: 3000
                    });
                } else {
                    dialogBox.close({
                        dialogName: 'input'
                    });

                    //上岗离岗保存
                    doSearchEmployee(index, empNo);
                }
            }
        });
    }

    //查询人员编码和名称
    function doSearchEmployee(index, empNo) {
        var un = localStorage.getItem('un');
        var serverUrl = localStorage.getItem('serverUrl');
        var url = serverUrl + "/app/getUtilComboxList";
        var data = {
            values: {
                tablename: "md_employee",
                column_name: "name",
                column_value: "code",
                condition: "is_delete=0 and ext15 = '" + empNo + "' ",
                un: un,
            }
        };
        var params = new Object();
        params.url = url;
        params.dataType = 'json';
        params.method = 'post';

        ajaxForData(params, data, false, function (ret, err) {
            if (ret) {
                var data = JSON.stringify(ret);
                var myobj = eval("(" + data + ")");

                //成功
                if (myobj.code == 0) {
                    var list = eval(myobj.list);
                    if (list == null || list.length < 2) {
                        api.toast({
                            msg: "卡号【" + empNo + "】在人员档案中不存在！",
                            duration: 3000
                        });
                    } else {
                        $("#empCode_" + index).html(list[1].value);
                        $("#empName_" + index).html(list[1].label);
                        $("#date_" + index).html(getNowDate());
                        document.getElementById("but_" + index + "_1").style.display = "block";
                        document.getElementById("but_" + index + "_2").style.display = "none";
                    }
                } else {
                    api.toast({
                        msg: myobj.message,
                        duration: 3000
                    });
                }
            } else {
                alert("网络连接超时!")
            }
        });
    }

    //提交
    function save() {
        var proddate = $("#prodDate").val();
        var shiftCode = $("#shiftCode").val();
        var teamCode = $("#teamCode").val();
        var type = $("#type").val();
        var empCode_1 = $("#empCode_1").html();
        var empName_1 = $("#empName_1").html();
        var date_1 = $("#date_1").html();
        var empCode_2 = $("#empCode_2").html();
        var empName_2 = $("#empName_2").html();
        var date_2 = $("#date_2").html();
        var empCode_3 = $("#empCode_3").html();
        var empName_3 = $("#empName_3").html();
        var date_3 = $("#date_3").html();
        var empCode_4 = $("#empCode_4").html();
        var empName_4 = $("#empName_4").html();
        var date_4 = $("#date_4").html();

        //表单非空校验
        var flag = formChk(proddate, shiftCode, teamCode, type);
        if (!flag) {
            return;
        }

        if (tableList == null || tableList.length == 0) {
            api.toast({
                msg: "没有需要保存的数据",
                duration: 3000
            });
            return;
        }

        var josnList = [];
        var count = 0
        var length = tableList.length
        for (var i = 0; i < tableList.length; i++) {

            //获取控件类型（0手动输入1多选2单选）
            // var controlType = list[i].controlType;
            var itemId = "citem" + i;
            var itemValue = "";

            //手动输入
            if ("0" == tableList[i].controlType) {

                itemValue = tableList[i].chkValue;

                //多选
            } else if ("1" == tableList[i].controlType) {

                var checkBoxObj = document.getElementsByName(itemId); //这个是以标签的name来取控件
                for (m = 0; m < checkBoxObj.length; m++) {
                    if (checkBoxObj[m].checked) {
                        itemValue = itemValue + checkBoxObj[m].value + ",";
                    }
                }
                if (checkBoxObj.length > 0) {
                    //有选中，则最后一个需要去掉“,”
                    itemValue = itemValue.substring(0, itemValue.length - 1);
                }

                //单选
            } else {
                var radioObj = document.getElementsByName(itemId); //这个是以标签的name来取控件
                for (n = 0; n < radioObj.length; n++) {
                    if (radioObj[n].checked) {
                        count++
                        itemValue = radioObj[n].value;
                    }
                }
            }
            chkTemplateId = tableList[i].chkTemplateId;
            josnList.push({
                "id": tableList[i].id,
                "chkValue": itemValue
            });
        }
        console.log(count)
        console.log(length)
        if (count != length) {
            api.toast({
                msg: "存在未点检项，请维护！",
                duration: 3000
            });
            return;
        }
        var un = localStorage.getItem('un');
        var serverUrl = localStorage.getItem('serverUrl');
        var url = serverUrl + "/app/getAssemblyChkTemplateSave";
        var data = {
            values: {
                workCenterCode: api.pageParam.workCenterCode,
                workCenterName: api.pageParam.workCenterName,
                workCellCode: api.pageParam.workCellCode,
                workCellName: api.pageParam.workCellName,
                chkBillId: chkBillId,
                proddate: proddate,
                shiftCode: shiftCode,
                teamCode: teamCode,
                type: type,
                chkTemplateId: chkTemplateId,
                josnList: JSON.stringify(josnList),
                empCode_1: empCode_1,
                empName_1: empName_1,
                date_1: date_1,
                empCode_2: empCode_2,
                empName_2: empName_2,
                date_2: date_2,
                empCode_3: empCode_3,
                empName_3: empName_3,
                date_3: date_3,
                empCode_4: empCode_4,
                empName_4: empName_4,
                date_4: date_4,
                un: un
            }
        };

        var params = new Object();
        params.url = url;
        params.dataType = 'json';
        params.method = 'post';

        api.showProgress({
            title: '保存中...',
        });

        ajaxForData(params, data, false, function (ret, err) {
            if (ret) {
                api.hideProgress();
                var data = JSON.stringify(ret);
                var myobj = eval("(" + data + ")");
                //成功
                if (myobj.code == 0) {
                    api.toast({
                        msg: "保存成功!",
                        duration: 3000
                    });

                    closeWin();
                } else {
                    api.toast({
                        msg: myobj.message,
                        duration: 3000
                    });
                }
            } else {
                api.hideProgress();
                alert("网络连接超时!")
            }
        });
    }

    function formChk(proddate, shiftCode, teamCode, type) {
        //计划日期非空校验
        if (proddate == null || proddate == "" || proddate == undefined) {
            api.toast({
                msg: "生产日期不能为空！",
                duration: 3000
            });
            return false;
        }

        //班次非空校验
        if (shiftCode == null || shiftCode == "" || shiftCode == undefined) {
            api.toast({
                msg: "班次不能为空！",
                duration: 3000
            });
            return false;
        }

        //班组非空校验
        if (teamCode == null || teamCode == "" || teamCode == undefined) {
            api.toast({
                msg: "班组不能为空！",
                duration: 3000
            });
            return false;
        }

        //类别非空校验
        if (type == null || type == "" || type == undefined) {
            api.toast({
                msg: "类别不能为空！",
                duration: 3000
            });
            return false;
        }
        return true;
    }

    //刷新按钮
    function refresh() {

        //获取设备唯一号
        equipUniqueId = localStorage.getItem('equipUniqueId');

        //检测单信息
        doSearch();
    }

    //返回按钮
    function closeWin() {
        api.closeToWin({ name: api.pageParam.rootName });
        api.execScript({
            name: api.pageParam.rootName,
            script: 'refresh()'
        });
    }
</script>

</html>